package com.pig4cloud.pig.admin.api.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Pattern;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.time.LocalDateTime;

/**
 * 字段表
 *
 * @author pig
 * @date 2024-09-23 17:31:09
 */
@Data
@TableName("meta_field")
@EqualsAndHashCode(callSuper = true)
@Schema(description = "字段表")
public class MetaFieldEntity extends Model<MetaFieldEntity> {


	/**
	 * id
	 */
	@TableId(type = IdType.ASSIGN_ID)
	@Schema(description = "id")
	private Long id;

	/**
	 * 字段显示名称
	 */
	@Schema(description = "字段显示名称")
	@TableField(value = "`name`")
	private String name;


	@Schema(description = "字段显示英文名称")
	@TableField(value = "`label`")
	@Pattern(regexp = "^[a-zA-Z][a-zA-Z0-9_]*$", message = "字段英文名称格式不正确")
	private String label;

	/**
	 * 字段物理名称
	 */
	@Schema(description = "字段物理名称")
	private String physicalName;

	/**
	 * 实体id
	 */
	@Schema(description = "实体id")
	private Long entityId;

	/**
	 * 字段显示排序
	 */
	@Schema(description = "字段显示排序")
	@TableField(value = "`order`")
	private Long order;

	/**
	 * 是否允许为空
	 */
	@Schema(description = "是否允许为空")
	private Integer nullable;

	/**
	 * 新建记录时允许修改字段
	 */
	@Schema(description = "新建记录时允许修改字段")
	private Integer creatable;

	/**
	 * 更新记录时允许修改字段
	 */
	@Schema(description = "更新记录时允许修改字段")
	private Integer updatable;

	/**
	 * 子表显示字段标识
	 */
	@Schema(description = "子表显示字段标识")
	private Integer childEntityFieldFlag;

	/**
	 * 是否父表id标识
	 */
	@Schema(description = "是否父表id标识")
	private Integer parentIdFieldFlag;

	/**
	 * 是否是系统保留字段
	 */
	@Schema(description = "是否是系统保留字段")
	private Integer systemFieldFlag;

	/**
	 * 字段视图json
	 */
	@Schema(description = "字段视图json")
	private String fieldViewModel;

	/**
	 * 是否换行
	 */
	@Schema(description = "是否换行")
	private Integer lineFlag;

	/**
	 * 类型
	 */
	@Schema(description = "类型")
	private String type;

	/**
	 * 创建人
	 */
	@TableField(fill = FieldFill.INSERT)
	@Schema(description = "创建人")
	private String createBy;

	/**
	 * 创建时间
	 */
	@TableField(fill = FieldFill.INSERT)
	@Schema(description = "创建时间")
	private LocalDateTime createTime;

	/**
	 * 修改人
	 */
	@TableField(fill = FieldFill.INSERT_UPDATE)
	@Schema(description = "修改人")
	private String updateBy;

	/**
	 * 更新时间
	 */
	@TableField(fill = FieldFill.INSERT_UPDATE)
	@Schema(description = "更新时间")
	private LocalDateTime updateTime;

	/**
	 * 删除标志
	 */
	@TableLogic
	@TableField(fill = FieldFill.INSERT)
	@Schema(description = "删除标志")
	private String delFlag;
}
